package com.luych.toolbox.common.feign.intf.base.service;

import com.luych.toolbox.common.constant.PageConstant;
import com.luych.toolbox.common.feign.FeignInterface;
import com.luych.toolbox.common.feign.param.base.service.LetterParam;
import com.luych.toolbox.common.feign.view.base.service.LetterView;
import com.luych.toolbox.common.page.CommonPageResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(contextId = "base-service-letter", name = "base-service", path = "/letter", decode404 = true)
public interface LetterFeign extends FeignInterface<LetterView, LetterParam> {

    @ApiOperation("按关键字查询站内信")
    @GetMapping("/search/keyword")
    CommonPageResult<LetterView> pageByKeyword(
            @ApiParam(value = "每页容量") @RequestHeader(name = "pageSize", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SIZE_STR) long pageSize,
            @ApiParam(value = "查询页码") @RequestHeader(name = "pageNumber", required = false, defaultValue = PageConstant.DEFAULT_PAGE_NUMBER_STR) long pageNumber,
            @ApiParam(value = "排序字段") @RequestHeader(name = "sort", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SORT) String sort,
            @ApiParam(value = "正序/倒序，取值ASC/DESC") @RequestHeader(name = "order", required = false, defaultValue = PageConstant.DEFAULT_PAGE_ORDER) String order,
            @ApiParam(value = "查询关键字，支持按标题和站内信模糊查询") @RequestParam(name = "keyword", required = false) String keyword,
            @ApiParam(value = "是否已读") @RequestParam(name = "readed", required = false) Boolean readed
    );


    @ApiOperation("标记为已读")
    @PatchMapping("/{id}/readed")
    void setReaded(
            @ApiParam(value = "站内信ID") @PathVariable("id") String id
    );

    @ApiOperation("标记为未读")
    @PatchMapping("/{id}/unread")
    void setUnread(
            @ApiParam(value = "站内信ID") @PathVariable("id") String id
    );

    @ApiOperation("全部标记为已读")
    @PatchMapping("/readed")
    int setReadedAll();

    @ApiOperation("全部标记为未读")
    @PatchMapping("/unread")
    int setUnreadAll();

    @ApiOperation("删除已读")
    @DeleteMapping("/readed")
    int deleteReaded();

    @ApiOperation("删除未读")
    @DeleteMapping("/unread")
    int deleteUnread();

    @ApiOperation("删除全部")
    @DeleteMapping
    int deleteAll();

}
